package com.playmodule.vr;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.SurfaceTexture;
import android.graphics.SurfaceTexture.OnFrameAvailableListener;
import android.hardware.Camera;
import android.opengl.GLES11Ext;
import android.opengl.GLES20;
import android.opengl.GLSurfaceView;
import android.opengl.GLUtils;
import android.opengl.Matrix;
import android.util.Log;
import android.view.Surface;

import com.hg.highglass_library.R;
import com.playmodule.MediaUtil;
import com.playmodule.vr.projections.Projection;
import com.playmodule.vr.projections.ProjectionFactory;
import com.playmodule.vr.utils.MatrixHelper;
import com.playmodule.vr.utils.TextResourceReader;

import org.hitlabnz.sensor_fusion_demo.orientationProvider.OrientationProvider;
import org.hitlabnz.sensor_fusion_demo.representation.Quaternion;
import org.hitlabnz.sensor_fusion_demo.representation.Vector3f;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

public class VrRenderer
        implements GLSurfaceView.Renderer, OnFrameAvailableListener {
    static final int COORDS_PER_UV = 2;
    static final int COORDS_PER_VERTEX = 3;
    private static int DEFAULT_FOV = 70;
    private static final int FLOAT_SIZE_BYTES = 4;
    public static final int SCREEN_MODE_LEFT = 1;
    public static final int SCREEN_MODE_PROXY = 3;
    public static final int SCREEN_MODE_RIGHT = 2;
    public static final int SCREEN_MODE_SPLIT = 0;
    private static String TAG = "VideoRender";
    private Bitmap mBitmap;
    private Quaternion mCalibration = new Quaternion();
    private Camera mCamera;
    private Projection mCameraProjection;
    private SurfaceTexture mCameraSurface;
    private int mCameraTextureID;
    private int mFov = DEFAULT_FOV;
    private String mImageFragmentShader;
    private boolean mImageMode;
    private int mImageProgram;
    private int mImageTextureID;
    private final float[] mMVPMatrix = new float[16];
    private boolean mPassThrough;
    private Projection mProjection;
    private final float[] mProjectionMatrix = new float[16];
    private float[] mSTMatrix = new float[16];
    private int mSceneAPositionHandle;
    private int mSceneATextureHandle;
    private int mSceneSTextureHandle;
    private int mSceneUMVPMatrixHandle;
    private int mSceneUSTMatrixHandle;
    private String mSceneVertexShader;
    private int mScreenMode;
    private boolean mTrackOrientation;
    private String mVideoFragmentShader;
    private int mVideoProgram;
    private SurfaceTexture mVideoSurface;
    private int mVideoTextureID;
    private final float[] mViewMatrix = new float[16];
    private int mViewportCenterPadding;
    private int mViewportHorizontalPadding;
    private int mViewportVerticalPadding;
    private OrientationProvider orientationProvider;
    private int surfaceHeight;
    private int surfaceWidth;
    private int surfaceWidthHalf;
    private final int textureStride = 8;
    private boolean updateSurface = false;
    private final int vertexStride = 12;
    private Quaternion centerQuaternion = null;

    public boolean hasCreated = false;
    private MediaUtil mediaUtil;


    public VrRenderer(Context p1, Projection p2) {
        mProjection = p2;
        mCameraProjection = ProjectionFactory.getInstance().CreateDefault();
        loadShaders(p1);
    }

    private void bindSceneProgram(int p1) {
        mSceneAPositionHandle = GLES20.glGetAttribLocation(p1, "aPosition");
        checkGlError("glGetAttribLocation aPosition");
        if (mSceneAPositionHandle == -0x1) {
            throw new RuntimeException("Could not get attrib location for aPosition");
        }
        mSceneATextureHandle = GLES20.glGetAttribLocation(p1, "aTextureCoord");
        checkGlError("glGetAttribLocation aTextureCoord");
        if (mSceneATextureHandle == -0x1) {
            throw new RuntimeException("Could not get attrib location for aTextureCoord");
        }
        mSceneUMVPMatrixHandle = GLES20.glGetUniformLocation(p1, "uMVPMatrix");
        checkGlError("glGetUniformLocation uMVPMatrix");
        if (mSceneUMVPMatrixHandle == -0x1) {
            throw new RuntimeException("Could not get uniform location for uMVPMatrix");
        }
        mSceneUSTMatrixHandle = GLES20.glGetUniformLocation(p1, "uSTMatrix");
        checkGlError("glGetUniformLocation uSTMatrix");
        if (mSceneUSTMatrixHandle == -0x1) {
            throw new RuntimeException("Could not get uniform location for uSTMatrix");
        }
        mSceneSTextureHandle = GLES20.glGetUniformLocation(p1, "sTexture");
        checkGlError("glGetUniformLocation sTexture");
        if (mSceneSTextureHandle == -0x1) {
            throw new RuntimeException("Could not get uniform location for sTexture");
        }
    }

    private void checkGlError(String p1) {
        int error = GLES20.glGetError();
        if (error != 0) {
            Log.e(TAG, ": glError " + error);
            throw new RuntimeException(": glError " + error);
        }
    }

    private int createProgram(String p1, String p2) {
        int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, p1);
        if (vertexShader == 0) {
            return 0x0;
        }
        int pixelShader = loadShader(GLES20.GL_FRAGMENT_SHADER, p2);
        if (pixelShader == 0) {
            return 0x0;
        }
        int program = GLES20.glCreateProgram();
        if (program != 0) {
            GLES20.glAttachShader(program, vertexShader);
            checkGlError("glAttachShader");
            GLES20.glAttachShader(program, pixelShader);
            checkGlError("glAttachShader");
            GLES20.glLinkProgram(program);
            int[] linkStatus = new int[0x1];
            GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, linkStatus, 0);
            if (linkStatus[0x0] != 0x1) {
                Log.e(TAG, "Could not link program: ");
                Log.e(TAG, GLES20.glGetProgramInfoLog(program));
                GLES20.glDeleteProgram(program);
                return program;
            }
        }
        return program;
    }

    private void createPrograms() {
        this.mVideoProgram = createProgram(this.mSceneVertexShader, this.mVideoFragmentShader);
        this.mImageProgram = createProgram(this.mSceneVertexShader, this.mImageFragmentShader);
    }

    public void createVideoSurfaceTexture() {
        try {
            mVideoSurface = new SurfaceTexture(mVideoTextureID);
            mVideoSurface.setOnFrameAvailableListener(this);
            Surface surface = new Surface(mVideoSurface);
            mediaUtil.getmMediaPlayer().setSurface(surface);
            surface.release();
            return;
        } catch (Exception localException1) {
        }
    }

    private void drawLeftScreen() {
        if (this.mProjection.isStereoscopic()) {
            Matrix.translateM(this.mMVPMatrix, 0, -65536.0F, 0.0F, 0.0F);
        }
        GLES20.glUniformMatrix4fv(this.mSceneUMVPMatrixHandle, 1, false, this.mMVPMatrix, 0);
//        if (HmdCtrl.isBigScreen()) {
//            GLES20.glViewport(-surfaceWidth / 2, -this.surfaceHeight / 2, this.surfaceWidth * 2, this.surfaceHeight * 2);
//        } else {
        GLES20.glViewport(0, 0, this.surfaceWidth, this.surfaceHeight);
//        }
        GLES20.glDrawElements(GLES20.GL_TRIANGLES, this.mProjection.getIndicesLength(), GLES20.GL_UNSIGNED_SHORT, this.mProjection.mIndicesBuffer);
        checkGlError("glDrawArrays");
    }

    private void drawRightScreen() {
        if (this.mProjection.isStereoscopic()) {
            Matrix.translateM(this.mMVPMatrix, 0, 65536.0F, 0.0F, 0.0F);
        }
        GLES20.glUniformMatrix4fv(this.mSceneUMVPMatrixHandle, 1, false, this.mMVPMatrix, 0);
//        if (HmdCtrl.isBigScreen()) {
//            GLES20.glViewport(-surfaceWidth / 2, -this.surfaceHeight / 2, this.surfaceWidth * 2, this.surfaceHeight * 2);
//        } else {
        GLES20.glViewport(0, 0, this.surfaceWidth, this.surfaceHeight);
//        }
        GLES20.glDrawElements(GLES20.GL_TRIANGLES, this.mProjection.getIndicesLength(), GLES20.GL_UNSIGNED_SHORT, this.mProjection.mIndicesBuffer);
        checkGlError("glDrawArrays");
    }

    private void drawSplitScreen() {
        int halfViewportCenterPadding = Math.abs(this.mViewportCenterPadding / 2);
        if (this.mProjection.isStereoscopic()) {
            Matrix.translateM(this.mMVPMatrix, 0, -65536.0F, 0.0F, 0.0F);
        }
        GLES20.glUniformMatrix4fv(this.mSceneUMVPMatrixHandle, 1, false, this.mMVPMatrix, 0);
//        if (HmdCtrl.isBigScreen()) {
//            GLES20.glScissor(-this.surfaceWidth / 4, -this.surfaceHeight / 2, this.surfaceWidth, this.surfaceHeight * 2);
//            GLES20.glViewport(-this.surfaceWidth / 4, -this.surfaceHeight / 2, this.surfaceWidth, this.surfaceHeight * 2);
//        } else {
        GLES20.glScissor(0, 0, this.surfaceWidthHalf, this.surfaceHeight);
        GLES20.glViewport(this.mViewportHorizontalPadding, this.mViewportVerticalPadding, this.surfaceWidthHalf - this.mViewportHorizontalPadding - halfViewportCenterPadding, this.surfaceHeight - 2 * this.mViewportVerticalPadding);
//        }
        GLES20.glDrawElements(GLES20.GL_TRIANGLES, this.mProjection.getIndicesLength(), GLES20.GL_UNSIGNED_SHORT, this.mProjection.mIndicesBuffer);
        checkGlError("glDrawArrays");
        if (this.mProjection.isStereoscopic()) {
            Matrix.translateM(this.mMVPMatrix, 0, 131072f, 0.0F, 0.0F);
        }
        GLES20.glUniformMatrix4fv(this.mSceneUMVPMatrixHandle, 1, false, this.mMVPMatrix, 0);
//        if (HmdCtrl.isBigScreen()) {
//            GLES20.glScissor(this.surfaceWidth / 2, -this.surfaceHeight / 2, this.surfaceWidth / 2, this.surfaceHeight * 2);
//            GLES20.glViewport(this.surfaceWidth / 4, -this.surfaceHeight / 2, this.surfaceWidth / 2, this.surfaceHeight * 2);
//        } else {
        GLES20.glScissor(this.surfaceWidthHalf, 0, this.surfaceWidthHalf, this.surfaceHeight);
        GLES20.glViewport(halfViewportCenterPadding + this.surfaceWidthHalf, this.mViewportVerticalPadding, this.surfaceWidthHalf - this.mViewportHorizontalPadding - halfViewportCenterPadding, this.surfaceHeight - 2 * this.mViewportVerticalPadding);
//        }
        GLES20.glDrawElements(GLES20.GL_TRIANGLES, this.mProjection.getIndicesLength(), GLES20.GL_UNSIGNED_SHORT, this.mProjection.mIndicesBuffer);
        checkGlError("glDrawArrays");
    }

    private void initMatrices() {
        Matrix.setLookAtM(this.mViewMatrix, 0, 0.0F, 1.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, -1.0F);
        MatrixHelper.perspectiveM(this.mProjectionMatrix, this.mFov, 1.0F, 0.0F, 10.0F);
        Matrix.setIdentityM(this.mMVPMatrix, 0);
    }

    private void initTextures() {
        int[] arrayOfInt = new int[3];
        GLES20.glGenTextures(3, arrayOfInt, 0);
        this.mVideoTextureID = arrayOfInt[0];
        this.mImageTextureID = arrayOfInt[1];
        this.mCameraTextureID = arrayOfInt[2];
        createVideoSurfaceTexture();
        createCameraSurfaceTexture();
    }

    private int loadShader(int paramInt, String paramString) {
        int i = GLES20.glCreateShader(paramInt);
        if (i != 0) {
            GLES20.glShaderSource(i, paramString);
            GLES20.glCompileShader(i);
            int[] arrayOfInt = new int[1];
            GLES20.glGetShaderiv(i, GLES20.GL_COMPILE_STATUS, arrayOfInt, 0);
            if (arrayOfInt[0] == 0) {
                Log.e(TAG, "Could not compile shader " + paramInt + ":");
                Log.e(TAG, GLES20.glGetShaderInfoLog(i));
                GLES20.glDeleteShader(i);
                return i;
            }
        }
        return i;
    }

    private void loadShaders(Context paramContext) {
        this.mSceneVertexShader = TextResourceReader.readTextFileFromResource(paramContext, R.raw.scene_vertex_shader);
        this.mVideoFragmentShader = TextResourceReader.readTextFileFromResource(paramContext, R.raw.video_fragment_shader);
        this.mImageFragmentShader = TextResourceReader.readTextFileFromResource(paramContext, R.raw.image_fragment_shader);
    }

    private void updateProjection() {
        float ratio;
//        if (HmdCtrl.isBigScreen()) {
////            ratio = (float) surfaceWidth / (float) surfaceHeight;
//            if (mScreenMode == 0) {
//                ratio = (float) surfaceWidthHalf / (float) surfaceHeight;
//            } else {
//                ratio = (float) surfaceWidth / (float) surfaceHeight;
//            }
//        } else {
        if (mScreenMode == 0) {
            ratio = (float) surfaceWidthHalf / (float) surfaceHeight;
        } else {
            ratio = (float) surfaceWidth / (float) surfaceHeight;
        }
//        }

        if (mPassThrough) {
            MatrixHelper.perspectiveM(mProjectionMatrix, 30.0f, 1.0f, 0.0f, 10.0f);
        } else {
            MatrixHelper.perspectiveM(mProjectionMatrix, (float) mFov, ratio, 0.0f, 10.0f);
        }

    }

    public void activateCamera() {
        deactivateCamera();
        try {
            this.mCamera = Camera.open();
            this.mCamera.setPreviewTexture(this.mCameraSurface);
            return;
        } catch (Exception localException) {
        }
    }

    public void bindImageTexture(Bitmap paramBitmap) {
        this.mImageMode = true;
        bindSceneProgram(this.mImageProgram);
        GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, this.mImageTextureID);
        GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
        GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
        GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
        GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
        GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, paramBitmap, 0);
        this.mBitmap = paramBitmap;

    }

    public void bindVideoTexture() {
        if (this.mBitmap != null) {
            this.mBitmap.recycle();
            this.mBitmap = null;
        }
        this.mImageMode = false;
        bindSceneProgram(this.mVideoProgram);
        GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
        GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, 0);

        if (this.mPassThrough) {
            GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, mVideoTextureID);
        } else {
            GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, mCameraTextureID);
        }
        GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
        GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
        GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
        GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
    }

    public void calibrate() {
        if (this.orientationProvider != null) {
            Quaternion localQuaternion1 = this.orientationProvider.getQuaternion();
            this.mCalibration.setXYZW(localQuaternion1.getX(), localQuaternion1.getY(), localQuaternion1.getZ(), -localQuaternion1.getW());
            Quaternion localQuaternion2 = new Quaternion();
            localQuaternion2.setAxisAngle(new Vector3f(0.0F, 1.0F, 0.0F), 90.0F);
            this.mCalibration.multiplyByQuat(localQuaternion2);
        }
    }

    public void createCameraSurfaceTexture() {
        if (this.mCameraTextureID <= 0) {
            return;
        }
        try {
            this.mCameraSurface = new SurfaceTexture(this.mCameraTextureID);
            this.mCameraSurface.setOnFrameAvailableListener(this);
            activateCamera();
            return;
        } catch (Exception localException) {
        }
    }

    public void deactivateCamera() {
        try {
            if (this.mCamera != null) {
                this.mCamera.stopPreview();
                this.mCamera.setPreviewCallback(null);
                this.mCamera.release();
                this.mCamera = null;
            }
            return;
        } catch (Exception localException) {
        }
    }

    public void onDrawFrame(GL10 glUnused) {
        synchronized (this) {
            try {
                if (mPassThrough) {
                    if (this.mCameraSurface != null && this.updateSurface) {
                        this.mCameraSurface.updateTexImage();
                        this.mCameraSurface.getTransformMatrix(this.mSTMatrix);
                        this.updateSurface = false;
                    }

                } else {
                    if (this.mVideoSurface != null && this.updateSurface) {
                        mVideoSurface.updateTexImage();
                        mVideoSurface.getTransformMatrix(this.mSTMatrix);
                        this.updateSurface = false;
                    }
                }
            } catch (Exception e) {

            }
        }
        GLES20.glClearColor(0.0F, 0.0F, 0.0F, 1.0F);
        GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
        if (mImageMode && !mPassThrough) {
            GLES20.glUseProgram(this.mImageProgram);
            checkGlError("glUseProgram");
            GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
            GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, this.mImageTextureID);
            GLES20.glUniform1i(this.mSceneSTextureHandle, 0);
            Matrix.setIdentityM(this.mSTMatrix, 0);
        } else {
            GLES20.glUseProgram(this.mVideoProgram);
            checkGlError("mVideoProgram");
        }
        GLES20.glVertexAttribPointer(this.mSceneAPositionHandle, 3, GLES20.GL_FLOAT, false, 12, this.mProjection.mVerticesBuffer);
        checkGlError("glVertexAttribPointer maPosition");
        GLES20.glEnableVertexAttribArray(this.mSceneAPositionHandle);
        checkGlError("glEnableVertexAttribArray maPositionHandle");
        GLES20.glVertexAttribPointer(this.mSceneATextureHandle, 2, GLES20.GL_FLOAT, false, 8, this.mProjection.mUVBuffer);
        checkGlError("glVertexAttribPointer maTextureHandle");
        GLES20.glEnableVertexAttribArray(this.mSceneATextureHandle);
        checkGlError("glEnableVertexAttribArray maTextureHandle");
        GLES20.glUniformMatrix4fv(this.mSceneUSTMatrixHandle, 1, false, this.mSTMatrix, 0);
        Matrix.multiplyMM(this.mMVPMatrix, 0, this.mProjectionMatrix, 0, this.mViewMatrix, 0);
//        if (HmdCtrl.isBigScreen()) {
//            Matrix.scaleM(this.mMVPMatrix, 0, 2, 4, 1);
//        }
        if (!mPassThrough && mTrackOrientation && orientationProvider != null) {
            Quaternion localQuaternion = this.orientationProvider.getQuaternion();
            if (localQuaternion == null || (localQuaternion.getX() == 0 && localQuaternion.getY() == 0 && localQuaternion.getZ() == 0 && localQuaternion.getW() == 1)) {
                Matrix.rotateM(this.mMVPMatrix, 0, -90.0F, 1.0F, 0.0F, 0.0F);
            } else {
                localQuaternion.multiplyByQuat(this.mCalibration);
//                if(mProjection instanceof HalfSphereProjection){
//                    double[] fuck = localQuaternion.toEulerAngles();
//                    if (Math.abs(fuck[0] * 180 / Math.PI) <= 35) {
//                        tmpX = (float) (fuck[0] * 180 / Math.PI);
//                    }
//                    if (fuck[2] * 180 / Math.PI <= 0) {
//                        if (fuck[2] * 180 / Math.PI <= -15 && fuck[2] * 180 / Math.PI >= -105)
//                            tmpY = (float) (fuck[2] * 180 / Math.PI);
//                    }
//                    float tmpZ = (float) (fuck[1] * 180 / Math.PI);
//                    localQuaternion.setEulerAngle(tmpY,tmpZ,tmpX);
//                }
                Log.e("fuck you",localQuaternion.getW()+"sssss");
                Matrix.rotateM(this.mMVPMatrix, 0, (float) (180.0D * (2.0D * Math.acos(localQuaternion.getW()) / Math.PI)), localQuaternion.getX(), localQuaternion.getZ(), -localQuaternion.getY());

            }
        } else {
            Matrix.rotateM(this.mMVPMatrix, 0, -90.0F, 1.0F, 0.0F, 0.0F);
        }
        switch (this.mScreenMode) {
            case 1:
                drawLeftScreen();
                break;
            case 2:
                drawRightScreen();
                break;
            case 3:
                drawLeftScreen();
                break;
            default:
                drawSplitScreen();
                break;
        }

        GLES20.glFinish();
    }

    @Override
    public void onFrameAvailable(SurfaceTexture surfaceTexture) {
        synchronized (this) {
            try {
                if (mPassThrough) {
                    if (mCameraSurface != null) {
                        updateSurface = true;
                    }
                } else {
                    if (mVideoSurface != null) {
                        updateSurface = true;
                    }
                }
            } catch (Exception e) {
            }
        }
    }

    public void onSurfaceChanged(GL10 paramGL10, int paramInt1, int paramInt2) {
        this.surfaceWidth = paramInt1;
        this.surfaceHeight = paramInt2;
        this.surfaceWidthHalf = (paramInt1 / 2);
        updateProjection();
    }

    public void setMediaHelper(MediaUtil mediaHelper) {
        this.mediaUtil = mediaHelper;
    }

    public void onSurfaceCreated(GL10 paramGL10, EGLConfig paramEGLConfig) {
        initMatrices();
        createPrograms();
        initTextures();
        bindVideoTexture();
        hasCreated = true;
    }

    public void init() {
        initTextures();
        bindVideoTexture();
    }

    public void setFov(int paramInt) {
        this.mFov = paramInt;
    }

    public void setOrientationProvider(OrientationProvider paramOrientationProvider) {
        this.orientationProvider = paramOrientationProvider;
    }

    public void setPassThrough(boolean paramBoolean) {
        mPassThrough = paramBoolean;
        if (mCamera == null) {
            activateCamera();
        }
        if (mCamera != null) {
            if (mPassThrough) {
                mCamera.startPreview();
            } else {
                mCamera.stopPreview();
            }
        }
        updateProjection();
        updateSurface = true;
    }

    public void setProjection(Projection paramProjection) {
        this.mProjection = paramProjection;
    }

    public void setScreenMode(int paramInt) {
//        Log.e("fuck you setScreenMode",mScreenMode+"setScreenMode");
        this.mScreenMode = paramInt;
        updateProjection();
    }

    public void setTrackOrientation(boolean paramBoolean) {
        this.mTrackOrientation = paramBoolean;
    }

    public void setViewportsPadding(int paramInt1, int paramInt2, int paramInt3) {
        this.mViewportHorizontalPadding = paramInt1;
        this.mViewportVerticalPadding = paramInt2;
        this.mViewportCenterPadding = paramInt3;
    }
}

